home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qasyncio.h.z / qasyncio.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  2.4 KB  |  104 lines

  1. /****************************************************************************
  2. ** $Id: qasyncio.h,v 1.5 1998/07/03 00:09:30 hanord Exp $
  3. **
  4. **              ***   INTERNAL HEADER FILE   ***
  5. **
  6. **        This file is NOT a part of the Qt interface!
  7. **
  8. ** Definition of asynchronous I/O classes
  9. **
  10. ** Created : 970617
  11. **
  12. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  13. **
  14. ** This file is part of Qt Free Edition, version 1.40.
  15. **
  16. ** See the file LICENSE included in the distribution for the usage
  17. ** and distribution terms, or http://www.troll.no/free-license.html.
  18. **
  19. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  20. ** your own programs or libraries.
  21. **
  22. ** Please see http://www.troll.no/pricing.html for information about 
  23. ** Qt Professional Edition, which is this same library but with a
  24. ** license which allows creation of commercial/proprietary software.
  25. **
  26. *****************************************************************************/
  27.  
  28. #ifndef QASYNCIO_H
  29. #define QASYNCIO_H
  30.  
  31. #ifndef QT_H
  32. #include "qobject.h"
  33. #include "qsignal.h"
  34. #include "qtimer.h"
  35. #endif // QT_H
  36.  
  37. class QIODevice;
  38.  
  39. class QAsyncIO {
  40. public:
  41.     virtual ~QAsyncIO();
  42.     void connect(QObject*, const char* member);
  43.  
  44. protected:
  45.     void ready();
  46.  
  47. private:
  48.     QSignal signal;
  49. };
  50.  
  51. class QDataSink : public QAsyncIO {
  52. public:
  53.     // Call this to know how much I can take.
  54.     virtual int readyToReceive()=0;
  55.     virtual void receive(const uchar*, int count)=0;
  56.     virtual void eof()=0;
  57.     void maybeReady();
  58. };
  59.  
  60. class QDataSource : public QAsyncIO {
  61. public:
  62.     virtual int readyToSend()=0; // returns -1 when never any more ready
  63.     virtual void sendTo(QDataSink*, int count)=0;
  64.     void maybeReady();
  65.  
  66.     virtual bool rewindable() const;
  67.     virtual void enableRewind(bool);
  68.     virtual void rewind();
  69. };
  70.  
  71. class QIODeviceSource : public QDataSource {
  72.     const int buf_size;
  73.     uchar *buffer;
  74.     QIODevice* iod;
  75.     bool rew;
  76.  
  77. public:
  78.     QIODeviceSource(QIODevice*, int bufsize=4096);
  79.    ~QIODeviceSource();
  80.  
  81.     int readyToSend();
  82.     void sendTo(QDataSink* sink, int n);
  83.     bool rewindable() const;
  84.     void enableRewind(bool on);
  85.     void rewind();
  86. };
  87.  
  88. class QDataPump : public QObject {
  89.     Q_OBJECT
  90.     int interval;
  91.     QTimer timer;
  92.     QDataSource* source;
  93.     QDataSink* sink;
  94.  
  95. public:
  96.     QDataPump(QDataSource*, QDataSink*);
  97.  
  98. private slots:
  99.     void kickStart();
  100.     void tryToPump();
  101. };
  102.  
  103. #endif
  104.